 public class t3{
        public static void main(String[] args) {
            boolean[] sushu = new boolean[20001];
            for (int i = 2; i <= 20000; i++) {
                sushu[i] = true;
            }
            for (int factor = 2; factor * factor <= 20000; factor++) {
                if (sushu[factor]) {
                    for (int multiple = factor * factor; multiple <= 20000; multiple += factor) {
                        sushu[multiple] = false;
                    }
                }
            }
            int count = 0;
            for (int i = 2; i <= 20000; i++) {
                if (sushu[i]) {
                    System.out.print(i + " ");
                    count++;
                    if (count % 5 == 0) {
                        System.out.println();
                    }
                }
            }
        }
    }
